      }
   }
}
 
class MessageGenerator extends Thread
{
   public void run()
   {
      while (true) {
         try { Thread.sleep(FWS.TransmitPeriod); }
         catch (InterruptedException e) {}
         for( Sensor s : FWS.sensors)
         		TransmitDriver.send(MessageFormat.create(Averager.get(s)));
      }
   }
}

class Averager
{
   static public int get(Sensor s)
   {
      Vector v = DataBanker.read(s.name);
      int valueSum = 0;
      int weightSum = 0;
      for (int i = 0; i < v.size(); i++) {
         SensorReading r = (SensorReading)v.elementAt(i);

         int weight = s.weight;
         valueSum += r.value * weight;
         weightSum += weight;
      }
      if (s.weight == 0)
      	return 0;
      return valueSum/weightSum;
   } 
}

class Sensor
{
		public String name;
		public int number;
		public int weight;
		public int period;
		
		public Sensor(String name, int number, int weight, int period){
			this.name = name;
			this.number = number;
			this.weight = weight;
			this.period = period;
		}
}
